import static org.junit.Assert.*;

import org.junit.Test;

import com.wirelesstransfer.activity.receive.Authenticate;


public class AuthenticateTest {

	private Authenticate auth;
	private String ip;
	private String code;

	public AuthenticateTest(){
		auth = new Authenticate();
		ip = "";
		code = "-1";
	}

	@Test
	public void testGetValueCodeEmptyField() {
		int expected = -2;
		assertEquals(auth.getValueCode(code),expected);
	}
	
	@Test
	public void testGetValueCodeToShort() {
		int expected = -2;
		code = "1";
		assertEquals(auth.getValueCode(code),expected);
	}
	
	@Test
	public void testGetValueCodeCorrect() {
		int expected = 123456;
		code = "123456";
		assertEquals(auth.getValueCode(code),expected);
	}

	@Test
	public void testGetValueIpEmpty() {
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpOneDot() {
		ip = "1.";
		assertNull(auth.getValueIp(ip));
	}
	@Test
	public void testGetValueIpTwoDots() {
		ip = "1.1.";
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpThreeDots() {
		ip = "1.1.1.";
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpCorrectNumberDots() {
		ip = "1.1.1.1";
		String expected = "1.1.1.1";
		assertEquals(auth.getValueIp(ip), expected);
	}
	
	@Test
	public void testGetValueIpToManyIntegersFirst() {
		ip = "1234.1.1.1";
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpToManyIntegersSecond() {
		ip = "1.1234.1.1";
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpToManyIntegersThird() {
		ip = "1.1.1234.1";
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpToManyIntegersLast() {
		ip = "1.1.1.1234";
		assertNull(auth.getValueIp(ip));
	}
	
	@Test
	public void testGetValueIpCorrectNumberFirst() {
		ip = "198.1.1.1";
		String expected = "198.1.1.1";
		assertEquals(auth.getValueIp(ip), expected);
	}
	
	@Test
	public void testGetValueIpCorrectNumberSecond() {
		ip = "1.198.1.1";
		String expected = "1.198.1.1";
		assertEquals(auth.getValueIp(ip), expected);
	}
	
	@Test
	public void testGetValueIpCorrectNumberThird() {
		ip = "1.1.198.1";
		String expected = "1.1.198.1";
		assertEquals(auth.getValueIp(ip), expected);
	}
	
	@Test
	public void testGetValueIpCorrectNumberLast() {
		ip = "1.1.1.198";
		String expected = "1.1.1.198";
		assertEquals(auth.getValueIp(ip), expected);
	}
	

}
